#include "Renderer/Renderer.hpp"
#include "Game/Level/LevelLoader.hpp"
#include "Game/Game.hpp"
#include "Game/Editor.hpp"

#include "GameOption.h"

#include <cmath>

int main(int argc, char** argv)
{
    GameOption gameOptions(argc,argv);

    sf::RenderWindow window;
    window.Create(sf::VideoMode(1024, 768, 32), "A Maze Ring", sf::Style::Close, sf::WindowSettings(32,8,2));

    // sf::RenderWindow App(sf::VideoMode(1024, 728, 32), "A Maze Ring");

    if ( gameOptions.bEditor )
    {
        if ( gameOptions.levelName.size() == 0 )
        {
            std::cerr << "Insert a map name" << std::endl;
            return -2;
        }

        Editor editor(&window,gameOptions.levelName);
        if ( !editor.load() )
        {
            std::cerr << "Fail to load the editor -> Closing" << std::endl;
            return -1;
        }

        editor.run();
    }
    else
    {
        Game game(&window);
        if ( !game.load() )
        {
            std::cerr << "Fail to load the game -> Closing" << std::endl;
            return -1;
        }

        game.run();
    }

    return EXIT_SUCCESS;
}
